From 7d98280f3e8bbf94653bb19c27de20438dc835b8 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sat, 19 Feb 2011 01:02:56 +0000 Subject: [PATCH] More function and variable documentation --- includes/parser/CoreLinkFunctions.php | 27 +++++++++++++ includes/parser/CoreParserFunctions.php | 52 +++++++++++++++++++++++++ includes/parser/CoreTagHooks.php | 7 ++++ includes/parser/LinkHolderArray.php | 1 + includes/parser/Parser.php | 9 ++++- includes/parser/ParserCache.php | 22 ++++++++++- includes/parser/ParserOptions.php | 3 ++ includes/parser/ParserOutput.php | 6 +++ includes/parser/Preprocessor_Hash.php | 4 +- includes/search/SearchEngine.php | 5 +++ 10 files changed, 133 insertions(+), 3 deletions(-) diff --git a/includes/parser/CoreLinkFunctions.php b/includes/parser/CoreLinkFunctions.php index 772ab0da0c..5c796494cc 100644 --- a/includes/parser/CoreLinkFunctions.php +++ b/includes/parser/CoreLinkFunctions.php @@ -10,11 +10,27 @@ * @ingroup Parser */ class CoreLinkFunctions { + /** + * @static + * @param $parser Parser_LinkHooks + * @return bool + */ static function register( $parser ) { $parser->setLinkHook( NS_CATEGORY, array( __CLASS__, 'categoryLinkHook' ) ); return true; } + /** + * @static + * @param $parser Parser + * @param $holders LinkHolderArray + * @param $markers LinkMarkerReplacer + * @param Title $title + * @param $titleText + * @param null $displayText + * @param bool $leadingColon + * @return bool + */ static function defaultLinkHook( $parser, $holders, $markers, Title $title, $titleText, &$displayText = null, &$leadingColon = false ) { if( isset($displayText) && $markers->findMarker( $displayText ) ) { @@ -28,6 +44,17 @@ class CoreLinkFunctions { return $holders->makeHolder( $title, isset($displayText) ? $displayText : $titleText, '', '', '' ); } + /** + * @static + * @param $parser Parser + * @param $holders LinkHolderArray + * @param $markers LinkMarkerReplacer + * @param Title $title + * @param $titleText + * @param null $sortText + * @param bool $leadingColon + * @return bool|string + */ static function categoryLinkHook( $parser, $holders, $markers, Title $title, $titleText, &$sortText = null, &$leadingColon = false ) { global $wgContLang; diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index d1ebc1553c..e59550a776 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -88,6 +88,12 @@ class CoreParserFunctions { } } + /** + * @static + * @param $parser Parser + * @param string $part1 + * @return array + */ static function intFunction( $parser, $part1 = '' /*, ... */ ) { if ( strval( $part1 ) !== '' ) { $args = array_slice( func_get_args(), 2 ); @@ -99,6 +105,13 @@ class CoreParserFunctions { } } + /** + * @static + * @param $parser Parser + * @param $date + * @param null $defaultPref + * @return mixed|string + */ static function formatDate( $parser, $date, $defaultPref = null ) { $df = DateFormatter::getInstance(); @@ -176,6 +189,12 @@ class CoreParserFunctions { return $wgContLang->ucfirst( $s ); } + /** + * @static + * @param $parser Parser + * @param string $s + * @return + */ static function lc( $parser, $s = '' ) { global $wgContLang; if ( is_callable( array( $parser, 'markerSkipCallback' ) ) ) { @@ -185,6 +204,12 @@ class CoreParserFunctions { } } + /** + * @static + * @param $parser Parser + * @param string $s + * @return + */ static function uc( $parser, $s = '' ) { global $wgContLang; if ( is_callable( array( $parser, 'markerSkipCallback' ) ) ) { @@ -223,6 +248,13 @@ class CoreParserFunctions { } } + /** + * @static + * @param $parser Parser + * @param string $num + * @param null $raw + * @return + */ static function formatNum( $parser, $num = '', $raw = null) { if ( self::israw( $raw ) ) { return $parser->getFunctionLang()->parseFormattedNumber( $num ); @@ -231,10 +263,23 @@ class CoreParserFunctions { } } + /** + * @static + * @param $parser Parser + * @param string $case + * @param string $word + * @return + */ static function grammar( $parser, $case = '', $word = '' ) { return $parser->getFunctionLang()->convertGrammar( $word, $case ); } + /** + * @static + * @param $parser Parser + * @param $user User + * @return + */ static function gender( $parser, $user ) { wfProfileIn( __METHOD__ ); $forms = array_slice( func_get_args(), 2); @@ -259,6 +304,13 @@ class CoreParserFunctions { wfProfileOut( __METHOD__ ); return $ret; } + + /** + * @static + * @param $parser Parser + * @param string $text + * @return + */ static function plural( $parser, $text = '' ) { $forms = array_slice( func_get_args(), 2 ); $text = $parser->getFunctionLang()->parseFormattedNumber( $text ); diff --git a/includes/parser/CoreTagHooks.php b/includes/parser/CoreTagHooks.php index 5718b06f51..480e3543b1 100644 --- a/includes/parser/CoreTagHooks.php +++ b/includes/parser/CoreTagHooks.php @@ -52,6 +52,13 @@ class CoreTagHooks { return array( Xml::escapeTagsOnly( $content ), 'markerType' => 'nowiki' ); } + /** + * @static + * @param $content + * @param $attributes + * @param $parser Parser + * @return + */ static function math( $content, $attributes, $parser ) { global $wgContLang; return $wgContLang->armourMath( MathRenderer::renderMath( $content, $attributes, $parser->getOptions() ) ); diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php index 4104289200..05519c496a 100644 --- a/includes/parser/LinkHolderArray.php +++ b/includes/parser/LinkHolderArray.php @@ -66,6 +66,7 @@ class LinkHolderArray { * parsing of interwiki links, and secondly to allow all existence checks and * article length checks (for stub links) to be bundled into a single query. * + * @param $nt Title */ function makeHolder( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { wfProfileIn( __METHOD__ ); diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index d343ba6eae..ad223106f6 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -119,7 +119,11 @@ class Parser { # Temporary # These are variables reset at least once per parse regardless of $clearState - var $mOptions; # ParserOptions object + + /** + * @var ParserOptions + */ + var $mOptions; var $mTitle; # Title context, used for self-link rendering and similar things var $mOutputType; # Output type, one of the OT_xxx constants var $ot; # Shortcut alias, see setOutputType() @@ -614,6 +618,9 @@ class Parser { return $this->mLinkID++; } + /** + * @return Language + */ function getFunctionLang() { global $wgLang, $wgContLang; diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php index 6192a1ec05..fbf7bb21c7 100644 --- a/includes/parser/ParserCache.php +++ b/includes/parser/ParserCache.php @@ -37,6 +37,11 @@ class ParserCache { $this->mMemc = $memCached; } + /** + * @param $article Article + * @param $hash + * @return mixed|string + */ protected function getParserOutputKey( $article, $hash ) { global $wgRequest; @@ -48,6 +53,10 @@ class ParserCache { return $key; } + /** + * @param $article Article + * @return mixed|string + */ protected function getOptionsKey( $article ) { $pageid = $article->getID(); return wfMemcKey( 'pcache', 'idoptions', "{$pageid}" ); @@ -62,6 +71,9 @@ class ParserCache { * $article. For example give a Chinese interface to a user with * English preferences. That's why we take into account *all* user * options. (r70809 CR) + * + * @param $article Article + * @param $popts ParserOptions */ function getETag( $article, $popts ) { return 'W/"' . $this->getParserOutputKey( $article, @@ -81,6 +93,9 @@ class ParserCache { * Used to provide a unique id for the PoolCounter. * It would be preferable to have this code in get() * instead of having Article looking in our internals. + * + * @param $article Article + * @param $popts ParserOptions */ public function getKey( $article, $popts, $useOutdated = true ) { global $wgCacheEpoch; @@ -160,7 +175,12 @@ class ParserCache { return $value; } - + /** + * @param $parserOutput ParserOutput + * @param $article Article + * @param $popts ParserOptions + * @return void + */ public function save( $parserOutput, $article, $popts ) { $expire = $parserOutput->getCacheExpiry(); diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index b8b2739777..c97502186b 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -43,6 +43,9 @@ class ParserOptions { var $mThumbSize; # Thumb size preferred by the user. var $mUserLang; # Language code of the User language. + /** + * @var User + */ var $mUser; # Stored user object var $mIsPreview = false; # Parsing the page for a "preview" operation var $mIsSectionPreview = false; # Parsing the page for a "preview" operation on a single section diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index caac802f43..d847fc7732 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -260,6 +260,12 @@ class ParserOutput extends CacheTime { $this->mImages[$name] = 1; } + /** + * @param $title Title + * @param $page_id + * @param $rev_id + * @return void + */ function addTemplate( $title, $page_id, $rev_id ) { $ns = $title->getNamespace(); $dbk = $title->getDBkey(); diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index cca03e77fc..45af9ee156 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -13,6 +13,9 @@ * @ingroup Parser */ class Preprocessor_Hash implements Preprocessor { + /** + * @var Parser + */ var $parser; const CACHE_VERSION = 1; @@ -81,7 +84,6 @@ class Preprocessor_Hash implements Preprocessor { function preprocessToObj( $text, $flags = 0 ) { wfProfileIn( __METHOD__ ); - // Check cache. global $wgMemc, $wgPreprocessorCacheThreshold; diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 984322d812..379b292682 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -22,6 +22,11 @@ class SearchEngine { var $namespaces = array( NS_MAIN ); var $showRedirects = false; + /** + * @var DatabaseBase + */ + protected $db; + function __construct($db = null) { if ( $db ) { $this->db = $db; -- 2.20.1